//
//  StatusCellBottomView.swift
//  01-界面搭建
//
//  Created by Apple on 15/11/8.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    //MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //MARk: - 懒加载控件
    private lazy var retweetedButton:UIButton = UIButton(title: " 转发", color: UIColor.darkGrayColor(), imgName: "timeline_icon_retweet")
    private lazy var commentButton:UIButton = UIButton(title: " 评论", color: UIColor.darkGrayColor(), imgName: "timeline_icon_comment")
    private lazy var likeButton:UIButton = UIButton(title: " 评论", color: UIColor.darkGrayColor(), imgName: "timeline_icon_unlike")
}
//MARK: - 设置界面
extension StatusCellBottomView {
    //设置控件
    private func setupUI() {
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        //自动布局
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.left.top.bottom.equalTo(self)
        }
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.bottom.width.equalTo(retweetedButton)
            make.left.equalTo(retweetedButton.snp_right)
            
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.bottom.width.equalTo(retweetedButton)
            make.left.equalTo(commentButton.snp_right)
            // make.right.top.bottom.equalTo(self.snp_right)
            make.right.equalTo(self.snp_right)
        }
        let w = 0.8
        let scale = 0.4
        let setV1:UIView = setLine()
        let setV2:UIView = setLine()
        addSubview(setV1)
        addSubview(setV2)
        setV1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
           
        }
        setV2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(  commentButton.snp_right)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo( commentButton.snp_height).multipliedBy(scale)
        }

    }
    //添加底部分割线
    private func setLine()->UIView {
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
}